<template>
  <div class="box">
    <img :src="require('../../assets/img/logo.jpg')" alt />
    <div class="xia">
      <div>
        <input type="text" value="手机号" v-model="user.phone" class="inp1"  />
      </div>
      <div>
        <input type="text" value="密码" v-model="user.password" class="inp2" />
        </div>
    <div>
        <button class="btn2" @click="register">注&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;册</button>
      </div>
    </div>
  </div>
</template>

<script>
import {reqRegister} from "../../http/api"
export default {
  data(){
    return{
      //1.初始化表单数据
      user:{
        phone:"",
        password:""
      }
    }
  },
  methods:{
    register(){
      //发请求
      reqRegister(this.user).then(res=>{
        // console.log(res)
        if(res.data.code==200){
          this.$router.replace('/login')
        }
      })
    }
  }
};
</script>

<style scoped>
.box {
  width: 100vw;
  height: 3rem;
  padding: 0.1rem;
  position: fixed;
  left: 0;
  top: 3rem;
}
img {
  width: 4.2rem;
  height: 1rem;
  display: block;
  margin: 0 auto;
}
.xia div{
    margin-top: 0.3rem;
    margin-left:0.6rem;
}
.inp1,.inp2{
    width: 5.5rem;
    height: 0.7rem;
    border: 0.01rem solid rgb(111, 110, 110);
    
}
.btn2{
    width:5.5rem;
    height: 1rem;
    background: gainsboro;
}
</style>